import request from '@/utils/request'
import { praseStrEmpty } from "@/utils/pid";
// 查询客户列表
export function listCustomer(query) {
  return request({
    url: '/system/customer/list',
    method: 'get',
    params: query
  })
}

// 查询单个客户
export function singlecustomer(customerId) {
  return request({
    url: '/system/customer/selectuserbyid/'+ praseStrEmpty(customerId),
    method: 'get',
  })
}

// 查询客户详细
export function getCustomer(customerId,userId) {
  return request({
    url: '/system/customer/' + praseStrEmpty(customerId)+'/'+ praseStrEmpty(userId),
    method: 'get'
  })
}

// // 查询客户详细By userId
// export function getCustomerByuserId(data) {
//   return request({
//     url: '/system/customer/getCustomerByuserId',
//     method: 'get',
//     data: data
//   })
// }

// 新增客户
export function addCustomer(data) {
  return request({
    url: '/system/customer',
    method: 'post',
    data: data
  })
}

// 修改客户
export function updateCustomer(data) {
  return request({
    url: '/system/customer',
    method: 'put',
    data: data
  })
}

// 删除客户
export function delCustomer(customerId) {
  return request({
    url: '/system/customer/' + customerId,
    method: 'delete'
  })
}

// 导出客户
export function exportCustomer(query) {
  return request({
    url: '/system/customer/export',
    method: 'get',
    params: query
  })
}

// 客户状态修改
export function changeCustomerStatus(userId,customerId, status) {
  const data = {
    userId,
    customerId,
    status
  }
  return request({
    url: '/system/customer/changeStatus',
    method: 'put',
    data: data
  })
}
